import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据


import { format,fromUnixTime } from 'date-fns';
export const columns: BasicColumn[] = [
  //  {
  //   title: '客户编码',
  //   align:"center",
  //   dataIndex: 'custCode'
  //  },
   {
    title: '入库单唯一键',
    align:"center",
    dataIndex: 'stockinId'
   },
   {
    title: '入库单号',
    align:"center",
    dataIndex: 'orderNo'
   },
  //  {
  //   title: '仓库编号',
  //   align:"center",
  //   dataIndex: 'warehouseNo'
  //  },
   {
    title: '入库单状态',
    align:"center",
    dataIndex: 'status_dictText'
   },
   {
    title: '货品数量',
    align:"center",
    dataIndex: 'goodsCount'
   },
   {
    title: '供应商编号',
    align:"center",
    dataIndex: 'providerNo'
   },
   {
    title: '供应商名称',
    align:"center",
    dataIndex: 'providerName'
   },

   {
    title: '最后修改时间',
    align:"center",
    dataIndex: 'modified',
    customRender: ({ text }) => {
     return format(fromUnixTime(text.substring(0, text.length - 3)), 'yyyy-MM-dd HH:mm:ss');
    }
   },
   {
    title: '制单时间',
    align:"center",
    dataIndex: 'createdTime',
    customRender: ({ text }) => {
     return format(fromUnixTime(text.substring(0, text.length - 3)), 'yyyy-MM-dd HH:mm:ss');
    }
   },
  //  {
  //   title: '入库单备注',
  //   align:"center",
  //   dataIndex: 'remark'
  //  },
  //  {
  //   title: '入库单物流类型',
  //   align:"center",
  //   dataIndex: 'logisticsTypeName'
  //  },
   {
    title: '入库单审核时间',
    align:"center",
    dataIndex: 'checkTime',
    customRender: ({ text }) => {
      return format(fromUnixTime(text.substring(0, text.length - 3)), 'yyyy-MM-dd HH:mm:ss');
    }
   },
   {
    title: '采购单唯一键',
    align:"center",
    dataIndex: 'purchaseId'
   },
   {
    title: '采购单号',
    align:"center",
    dataIndex: 'purchaseNo'
   },
  
  //  {
  //   title: '物流单号',
  //   align:"center",
  //   dataIndex: 'logisticsNo'
  //  },
  //  {
  //   title: '物流公司',
  //   align:"center",
  //   dataIndex: 'logisticsName'
  //  },
  //  {
  //   title: '货品总价格，不包含优惠',
  //   align:"center",
  //   dataIndex: 'goodsAmount'
  //  },
  //  {
  //   title: '税前总货款（折后）',
  //   align:"center",
  //   dataIndex: 'totalPrice'
  //  },
  //  {
  //   title: '税后总额（折后）',
  //   align:"center",
  //   dataIndex: 'taxAmount'
  //  },
  //  {
  //   title: '明细入库价*数量之和',
  //   align:"center",
  //   dataIndex: 'totalStockinPrice'
  //  },
  //  {
  //   title: '标记名称',
  //   align:"center",
  //   dataIndex: 'flagName'
  //  },
   {
    title: '经办人',
    align:"center",
    dataIndex: 'operatorName'
   },
   {
    title: '创建时间',
    align:"center",
    dataIndex: 'gmtCreate'
   },
   {
    title: '修改时间',
    align:"center",
    dataIndex: 'gmtUpdate',
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "入库单号",
      field: "orderNo",
      component: 'Input',
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '客户编码',
    field: 'custCode',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入客户编码!'},
          ];
     },
  },
  {
    label: '入库单唯一键',
    field: 'stockinId',
    component: 'InputNumber',
  },
  {
    label: '入库单号',
    field: 'orderNo',
    component: 'Input',
  },
  {
    label: '仓库编号',
    field: 'warehouseNo',
    component: 'Input',
  },
  {
    label: '入库单状态 10:已取消,20编辑中,30:待审核,37:待质检,40:质检确认,80:已完成',
    field: 'status',
    component: 'InputNumber',
  },
  {
    label: '最后修改时间',
    field: 'modified',
    component: 'Input',
  },
  {
    label: '制单时间',
    field: 'createdTime',
    component: 'Input',
  },
  {
    label: '入库单备注',
    field: 'remark',
    component: 'Input',
  },
  {
    label: '入库单物流类型',
    field: 'logisticsTypeName',
    component: 'Input',
  },
  {
    label: '入库单审核时间',
    field: 'checkTime',
    component: 'Input',
  },
  {
    label: '采购单唯一键',
    field: 'purchaseId',
    component: 'InputNumber',
  },
  {
    label: '采购单号',
    field: 'purchaseNo',
    component: 'Input',
  },
  {
    label: '货品数量',
    field: 'goodsCount',
    component: 'InputNumber',
  },
  {
    label: '供应商编号',
    field: 'providerNo',
    component: 'Input',
  },
  {
    label: '供应商名称',
    field: 'providerName',
    component: 'Input',
  },
  {
    label: '物流单号',
    field: 'logisticsNo',
    component: 'Input',
  },
  {
    label: '物流公司',
    field: 'logisticsName',
    component: 'Input',
  },
  {
    label: '货品总价格，不包含优惠',
    field: 'goodsAmount',
    component: 'InputNumber',
  },
  {
    label: '税前总货款（折后）',
    field: 'totalPrice',
    component: 'InputNumber',
  },
  {
    label: '税后总额（折后）',
    field: 'taxAmount',
    component: 'InputNumber',
  },
  {
    label: '明细入库价*数量之和',
    field: 'totalStockinPrice',
    component: 'InputNumber',
  },
  {
    label: '标记名称',
    field: 'flagName',
    component: 'Input',
  },
  {
    label: '经办人',
    field: 'operatorName',
    component: 'Input',
  },
  {
    label: '创建时间',
    field: 'gmtCreate',
    component: 'DatePicker',
    componentProps: {
       showTime:true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入创建时间!'},
          ];
     },
  },
  {
    label: '修改时间',
    field: 'gmtUpdate',
    component: 'DatePicker',
    componentProps: {
       showTime:true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入修改时间!'},
          ];
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表表格配置
export const stockinPurchaseOrderDetailsColumns: JVxeColumn[] = [
    // {
    //   title: '客户编码',
    //   key: 'custCode',
    //   type: JVxeTypes.input,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    //     validateRules: [
    //       { required: true, message: '${title}不能为空' },
    //     ],
    // },
    {
      title: '入库主单ID',
      key: 'stockinId',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '入库单号',
      key: 'orderNo',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    // {
    //   title: '入库单明细id',
    //   key: 'recId',
    //   type: JVxeTypes.inputNumber,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    {
      title: '数量',
      key: 'num',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    // {
    //   title: '折扣',
    //   key: 'discount',
    //   type: JVxeTypes.inputNumber,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    // {
    //   title: '税前单价',
    //   key: 'costPrice',
    //   type: JVxeTypes.inputNumber,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    // {
    //   title: '税前折后单价',
    //   key: 'srcPrice',
    //   type: JVxeTypes.inputNumber,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    // {
    //   title: '税后单价（折后）',
    //   key: 'taxPrice',
    //   type: JVxeTypes.inputNumber,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    // {
    //   title: '税后金额（税后总价）',
    //   key: 'taxAmount',
    //   type: JVxeTypes.inputNumber,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    // {
    //   title: '税率',
    //   key: 'tax',
    //   type: JVxeTypes.inputNumber,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    // {
    //   title: '税前金额（税前总价）',
    //   key: 'totalCost',
    //   type: JVxeTypes.inputNumber,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    // {
    //   title: '入库单明细备注',
    //   key: 'remark',
    //   type: JVxeTypes.input,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    {
      title: '货品名称',
      key: 'goodsName',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '货品编号',
      key: 'goodsNo',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    // {
    //   title: '商家编码',
    //   key: 'specNo',
    //   type: JVxeTypes.input,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    {
      title: '规格码',
      key: 'specCode',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    // {
    //   title: '采购明细自定义属性1',
    //   key: 'prop1',
    //   type: JVxeTypes.input,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    // {
    //   title: '采购明细自定义属性2',
    //   key: 'prop2',
    //   type: JVxeTypes.input,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    // {
    //   title: '采购明细自定义属性3',
    //   key: 'prop3',
    //   type: JVxeTypes.input,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    // {
    //   title: '采购明细自定义属性4',
    //   key: 'prop4',
    //   type: JVxeTypes.input,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    {
      title: '规格名称',
      key: 'specName',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '品牌名称',
      key: 'brandName',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '基本单位',
      key: 'unitName',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '若无批次则返回空字符串',
      key: 'batchNo',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '若无有效期则返回空字符串',
      key: 'expireDate',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '若无生产日期则返回空字符串',
      key: 'productionDate',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '货位',
      key: 'positionNo',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '是否残品 true：是 false：否',
      key: 'defect',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '换算系数',
      key: 'unitRatio',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '辅助单位',
      key: 'purchaseUnitName',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '入库价',
      key: 'stockinPrice',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '创建时间',
      key: 'gmtCreate',
      type: JVxeTypes.datetime,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '修改时间',
      key: 'gmtUpdate',
      type: JVxeTypes.datetime,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
  ]


// 高级查询数据
export const superQuerySchema = {
  custCode: {title: '客户编码',order: 0,view: 'text', type: 'string',},
  stockinId: {title: '入库单唯一键',order: 1,view: 'number', type: 'number',},
  orderNo: {title: '入库单号',order: 2,view: 'text', type: 'string',},
  warehouseNo: {title: '仓库编号',order: 3,view: 'text', type: 'string',},
  status: {title: '入库单状态 10:已取消,20编辑中,30:待审核,37:待质检,40:质检确认,80:已完成',order: 4,view: 'number', type: 'number',},
  modified: {title: '最后修改时间',order: 5,view: 'text', type: 'string',},
  createdTime: {title: '制单时间',order: 6,view: 'text', type: 'string',},
  remark: {title: '入库单备注',order: 7,view: 'text', type: 'string',},
  logisticsTypeName: {title: '入库单物流类型',order: 8,view: 'text', type: 'string',},
  checkTime: {title: '入库单审核时间',order: 9,view: 'text', type: 'string',},
  purchaseId: {title: '采购单唯一键',order: 10,view: 'number', type: 'number',},
  purchaseNo: {title: '采购单号',order: 11,view: 'text', type: 'string',},
  goodsCount: {title: '货品数量',order: 12,view: 'number', type: 'number',},
  providerNo: {title: '供应商编号',order: 13,view: 'text', type: 'string',},
  providerName: {title: '供应商名称',order: 14,view: 'text', type: 'string',},
  logisticsNo: {title: '物流单号',order: 15,view: 'text', type: 'string',},
  logisticsName: {title: '物流公司',order: 16,view: 'text', type: 'string',},
  goodsAmount: {title: '货品总价格，不包含优惠',order: 17,view: 'number', type: 'number',},
  totalPrice: {title: '税前总货款（折后）',order: 18,view: 'number', type: 'number',},
  taxAmount: {title: '税后总额（折后）',order: 19,view: 'number', type: 'number',},
  totalStockinPrice: {title: '明细入库价*数量之和',order: 20,view: 'number', type: 'number',},
  flagName: {title: '标记名称',order: 21,view: 'text', type: 'string',},
  operatorName: {title: '经办人',order: 22,view: 'text', type: 'string',},
  gmtCreate: {title: '创建时间',order: 23,view: 'datetime', type: 'string',},
  gmtUpdate: {title: '修改时间',order: 24,view: 'datetime', type: 'string',},
  //子表高级查询
  stockinPurchaseOrderDetails: {
    title: '采购入库单详情',
    view: 'table',
    fields: {
        custCode: {title: '客户编码',order: 0,view: 'text', type: 'string',},
        stockinId: {title: '与主表stockin_id关联',order: 1,view: 'number', type: 'number',},
        orderNo: {title: '入库单号',order: 2,view: 'text', type: 'string',},
        recId: {title: '入库单明细id',order: 3,view: 'number', type: 'number',},
        num: {title: '数量',order: 4,view: 'number', type: 'number',},
        discount: {title: '折扣',order: 5,view: 'number', type: 'number',},
        costPrice: {title: '税前单价',order: 6,view: 'number', type: 'number',},
        srcPrice: {title: '税前折后单价',order: 7,view: 'number', type: 'number',},
        taxPrice: {title: '税后单价（折后）',order: 8,view: 'number', type: 'number',},
        taxAmount: {title: '税后金额（税后总价）',order: 9,view: 'number', type: 'number',},
        tax: {title: '税率',order: 10,view: 'number', type: 'number',},
        totalCost: {title: '税前金额（税前总价）',order: 11,view: 'number', type: 'number',},
        remark: {title: '入库单明细备注',order: 12,view: 'text', type: 'string',},
        goodsName: {title: '货品名称',order: 13,view: 'text', type: 'string',},
        goodsNo: {title: '货品编号',order: 14,view: 'text', type: 'string',},
        specNo: {title: '商家编码',order: 15,view: 'text', type: 'string',},
        specCode: {title: '规格码',order: 16,view: 'text', type: 'string',},
        prop1: {title: '采购明细自定义属性1',order: 17,view: 'text', type: 'string',},
        prop2: {title: '采购明细自定义属性2',order: 18,view: 'text', type: 'string',},
        prop3: {title: '采购明细自定义属性3',order: 19,view: 'text', type: 'string',},
        prop4: {title: '采购明细自定义属性4',order: 20,view: 'text', type: 'string',},
        specName: {title: '规格名称',order: 21,view: 'text', type: 'string',},
        brandName: {title: '品牌名称',order: 22,view: 'text', type: 'string',},
        unitName: {title: '基本单位',order: 23,view: 'text', type: 'string',},
        batchNo: {title: '若无批次则返回空字符串',order: 24,view: 'text', type: 'string',},
        expireDate: {title: '若无有效期则返回空字符串',order: 25,view: 'text', type: 'string',},
        productionDate: {title: '若无生产日期则返回空字符串',order: 26,view: 'text', type: 'string',},
        positionNo: {title: '货位',order: 27,view: 'text', type: 'string',},
        defect: {title: '是否残品 true：是 false：否',order: 28,view: 'number', type: 'number',},
        unitRatio: {title: '换算系数',order: 29,view: 'number', type: 'number',},
        purchaseUnitName: {title: '辅助单位',order: 30,view: 'text', type: 'string',},
        stockinPrice: {title: '入库价',order: 31,view: 'number', type: 'number',},
        gmtCreate: {title: '创建时间',order: 32,view: 'datetime', type: 'string',},
        gmtUpdate: {title: '修改时间',order: 33,view: 'datetime', type: 'string',},
    }
  },
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
